import sqlite3
import pandas as pd
import matplotlib.pyplot as plt

conn = sqlite3.connect("example.db")
df = pd.read_sql("select * from daily",conn)
plt.figure(figsize=(12,6))
plt.plot(df['trade_date'],df['open'],label='002642',color='b')
plt.plot(df['trade_date'],df['low'])
plt.plot(df['trade_date'],df['high'])
plt.plot(df['trade_date'],df['close'])
plt.xlabel('trade_date')
plt.ylabel('open')
plt.title('002642')
plt.legend()
plt.grid()
plt.show()

df = pd.read_sql("select * from realtime_quotes",conn)
conn.close()

with sqlite3.connect("example.db") as conn:
    df = pd.read_sql("select * from daily",conn)
    df = pd.read_sql("select * from realtime_quotes",conn)
